<?php
###############   COPYLEFT GPLv3 LICENSE   ###############
##
## JFX Version 0.2.9
## Website Management Software
## www.jfxcms.com
##
## Copyright 2009 GPLv3 - http://www.opensource.org/licenses/gpl-3.0.html
##
## Anthony Gallon
## oi_antz@hotmail.com
##
## Permission is hereby granted to any person having a copy of this software
## to freely use and modify as required so long as the copyright notices
## and branding remain intact.
##
## Full license details available at http://www.jfxcms.com/license
##
###############   COPYLEFT GPLv3 LICENSE   ###############




function JFX_ExportPage_MakeTree($arr){
    $CONFIG = JFX::registry('config');
    $USER = JFX::registry('JFX_User');
    $LANG = JFX::registry('lang');
    $returnString = '';
    foreach($arr as $k=>$v){

        $link = '<a href="'.$CONFIG->adminUrl.'/export/export-page/?page='.$v['id'].'">'.$LANG->getContent('core', 'heading', $v['id']).'</a>';
        if(isset($v['subpages']) && count($v['subpages'])>0){
            $subpages = '<ul>'.JFX_ExportPage_MakeTree($v['subpages']).'</ul>';
        }else{
            $subpages = '';
        }
        $returnString .= '<li class="redirect">'.$link.$subpages.'</li>';
    }

    return $returnString;
}



function JFX_ImportBlock_MakeTree($arr, $idPrefix='page_', $workspaceid=''){
    $CONFIG = JFX::registry('config');
    $LANG = JFX::registry('lang');
    $USER = JFX::registry('JFX_User');
    if($workspaceid == '') $workspaceid = $USER->workspace;
    $returnString = '';
    foreach($arr as $k=>$v){

        $link = '<a href="javascript: void(null)" id="'.$idPrefix.$v['id'].'">'.$LANG->getContent('core', 'heading', $v['id'], '', $workspaceid).'</a>';
        if(isset($v['subpages']) && count($v['subpages'])>0){
            $subpages = '<ul>'.JFX_ImportBlock_MakeTree($v['subpages'], $idPrefix, $workspaceid).'</ul>';
        }else{
            $subpages = '';
        }
        $returnString .= '<li>'.$link.$subpages.'</li>';
    }

    return $returnString;
}







function JFX_ImportPage_MakeTree($arr, $idPrefix='page_', $workspaceid=1){
    $CONFIG = JFX::registry('config');
    $LANG = JFX::registry('lang');
    $returnString = '';
    foreach($arr as $k=>$v){

        $link = '<a href="javascript: void(null)" id="'.$idPrefix.$v['id'].'">'.$LANG->getContent('core', 'heading', $v['id'], '', $workspaceid).'</a>';
        if(isset($v['subpages']) && count($v['subpages'])>0){
            $subpages = '<ul>'.JFX_ImportPage_MakeTree($v['subpages'], $idPrefix, $workspaceid).'</ul>';
        }else{
            $subpages = '';
        }
        $returnString .= '<li>'.$link.$subpages.'</li>';
    }

    return $returnString;
}



